package com.rgz.service.WhdService.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rgz.mapper.CarinsuranceidMapper;
import com.rgz.mapper.InsuranceMapper;
import com.rgz.mapper.InsuredMapper;
import com.rgz.mapper.PolicyMapper;
import com.rgz.pojo.Carinsuranceid;
import com.rgz.pojo.CarinsuranceidExample;
import com.rgz.pojo.Insurance;
import com.rgz.pojo.InsuranceExample;
import com.rgz.pojo.Insured;
import com.rgz.pojo.InsuredExample;
import com.rgz.pojo.InsuredExample.Criteria;
import com.rgz.pojo.Policy;
import com.rgz.pojo.PolicyExample;
import com.rgz.service.WhdService.Whd_autoService;



@Service
public class Whd_autoServiceImpl implements Whd_autoService {
		@Autowired
		private InsuredMapper insuredMapper;
		@Autowired
		private PolicyMapper policyMapper;
		@Autowired
		private InsuranceMapper insuranceMapper;
		@Autowired
		private CarinsuranceidMapper carinsuranceidMapper;
	
	
		
		//判断查询方法
	public boolean atuo(Insured idsured) {
		InsuredExample  insuredExample=new InsuredExample();
		
		Criteria criteria = insuredExample.createCriteria();
		criteria.andIdentityEqualTo(idsured.getIdentity());
		
		List<Insured> list=insuredMapper.selectByExample(insuredExample);
		if (list!=null&&list.size()>0) {
			return true;
		}
		return false;
	}
	@Override
	public List<Policy> selectByExample(PolicyExample example) {
		
		return policyMapper.selectByExample(example) ;
	}
	@Override
	public boolean inset(Policy record) {
	int	i=policyMapper.insert(record);
		if(i>0){
			return true;
		}
		return false;
	}
	//通过ID进行查询险种
	@Override
	public List<Insurance> selectByExample(InsuranceExample example) {
		// TODO Auto-generated method stub
		return insuranceMapper.selectByExample(example) ;
	}
	//通过查询身份证 进行修改
	@Override
	public int updateByPrimaryKey(Policy policy,PolicyExample example) {
		return policyMapper.updateByExampleSelective(policy, example);
	}
	//添加车型表单
	@Override
	public int insert(Carinsuranceid record) {
		
		return carinsuranceidMapper.insert(record);
	}
	
	//添加被保人表单
	@Override
	public int insert(Insured record) {
		
		return insuredMapper.insert(record);
	}
	@Override
	public int updateByExampleSelective(Policy record, PolicyExample example) {
		
		return policyMapper.updateByExampleSelective(record, example);
	}
	@Override
	public List<Carinsuranceid> selectByExample(CarinsuranceidExample example) {
		
		return carinsuranceidMapper.selectByExample(example);
	}
	


	


}


